package com.hiultra.archive.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.hiultra.archive.domain.ArchiveStorage;
import com.hiultra.archive.service.IArchiveStorageService;
import com.hiultra.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.common.core.page.TableDataInfo;

/**
 * 档案入库列表Controller
 * 
 * @author ruoyi
 * @date 2024-07-22
 */
@RestController
@RequestMapping("/archive/storage")
public class ArchiveStorageController extends BaseController
{
    @Autowired
    private IArchiveStorageService archiveStorageService;

    /**
     * 查询档案入库列表列表
     */
    @PreAuthorize("@ss.hasPermi('archive:storage:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArchiveStorage archiveStorage)
    {
        startPage();
        List<ArchiveStorage> list = archiveStorageService.selectArchiveStorageList(archiveStorage);
        return getDataTable(list);
    }

    /**
     * 导出档案入库列表列表
     */
    @PreAuthorize("@ss.hasPermi('archive:storage:export')")
    @Log(title = "档案入库列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArchiveStorage archiveStorage)
    {
        List<ArchiveStorage> list = archiveStorageService.selectArchiveStorageList(archiveStorage);
        ExcelUtil<ArchiveStorage> util = new ExcelUtil<ArchiveStorage>(ArchiveStorage.class);
        util.exportExcel(response, list, "档案入库列表数据");
    }

    /**
     * 获取档案入库列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:storage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(archiveStorageService.selectArchiveStorageById(id));
    }

    /**
     * 根据任务id获取档案入库列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:storage:query')")
    @GetMapping(value = "/selectArchiveStorageByTaskBoxId/{taskBoxId}")
    public AjaxResult selectArchiveStorageByTaskId(@PathVariable("taskBoxId") String taskBoxId)
    {
        return AjaxResult.success(archiveStorageService.selectArchiveStorageByTaskBoxId(taskBoxId));
    }

    /**
     * 新增档案入库列表
     */
    @PreAuthorize("@ss.hasPermi('archive:storage:add')")
    @Log(title = "档案入库列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArchiveStorage archiveStorage)
    {
        return toAjax(archiveStorageService.insertArchiveStorage(archiveStorage));
    }

    /**
     * 修改档案入库列表
     */
    @PreAuthorize("@ss.hasPermi('archive:storage:edit')")
    @Log(title = "档案入库列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArchiveStorage archiveStorage)
    {
        return toAjax(archiveStorageService.updateArchiveStorage(archiveStorage));
    }

    /**
     * 删除档案入库列表
     */
    @PreAuthorize("@ss.hasPermi('archive:storage:remove')")
    @Log(title = "档案入库列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(archiveStorageService.deleteArchiveStorageByIds(ids));
    }
}
